package cn.charmaine.org.service.impl;

import cn.charmaine.basic.base.query.BaseQuery;
import cn.charmaine.basic.util.PageList;
import cn.charmaine.org.domain.DetailPage;
import cn.charmaine.org.domain.SystemDictionaryDetail;
import cn.charmaine.org.mapper.ISystemDictionaryDetailMapper;
import cn.charmaine.org.service.ISystemDictionaryDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class SystemDictionaryDetailServiceImpl implements ISystemDictionaryDetailService {
    @Autowired
    private ISystemDictionaryDetailMapper systemDictionaryDetailMapper;

    @Override
    @Transactional
    public void add(SystemDictionaryDetail systemDictionaryDetail) {
        systemDictionaryDetailMapper.insert(systemDictionaryDetail);
    }

    @Override
    @Transactional
    public void deleteById(Long id) {
        systemDictionaryDetailMapper.deleteById(id);
    }

    @Override
    @Transactional
    public void update(SystemDictionaryDetail systemDictionaryDetail) {
        systemDictionaryDetailMapper.update(systemDictionaryDetail);
    }

    @Override
    public SystemDictionaryDetail queryById(Long id) {
        return systemDictionaryDetailMapper.selectById(id);
    }

    @Override
    public List<SystemDictionaryDetail> queryAll() {
        return systemDictionaryDetailMapper.selectAll();
    }

    @Override
    public PageList<SystemDictionaryDetail> queryData(BaseQuery query) {
        return null;
    }

    @Override
    @Transactional
    public void batchDelete(List<Long> ids) {

    }

    @Override
    public PageList<SystemDictionaryDetail> queryByTypeId(DetailPage detailPage) {
        Long countNum = systemDictionaryDetailMapper.countNum(detailPage.getTypeId());
        List<SystemDictionaryDetail> list = systemDictionaryDetailMapper.selectByTypeId(detailPage);
        //list.forEach(System.out::println);
        return new PageList<>(countNum,list);
    }
}
